package com.antis.olsl.magic.outbound;

import android.text.TextUtils;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.antis.olsl.arouterlib.MagicRoutePath;
import com.antis.olsl.base.BaseActivity;
import com.antis.olsl.base.utils.ToastUtil;
import com.antis.olsl.magic.databinding.ActivityOutboundDetailBinding;
import com.antis.olsl.magic.response.GetExWarehouseTopListResp;

/**
 * 出库Top详情
 *
 * @author hhh
 */
@Route(path = MagicRoutePath.ACTIVITY_OUTBOUND_DETAIL)
public class OutboundDetailActivity extends BaseActivity<ActivityOutboundDetailBinding> {

    @Autowired
    GetExWarehouseTopListResp.ContentBean bean;
    @Autowired
    int type;

    @Override
    protected ActivityOutboundDetailBinding getViewBinding() {
        return ActivityOutboundDetailBinding.inflate(getLayoutInflater(), baseBinding.getRoot(), true);
    }

    @Override
    protected void initViews() {
        ARouter.getInstance().inject(this);
        if (null == bean) {
            ToastUtil.showToast(this, "数据为空");
            return;
        }

        if (!TextUtils.isEmpty(bean.productName)) {
            viewBinding.textProductNameTop.setText(bean.productName);
            viewBinding.textProductName.setText(bean.productName);
        }

        if (!TextUtils.isEmpty(bean.productCode)) {
            viewBinding.textProductCodeTop.setText(bean.productCode);
            viewBinding.textProductCode.setText(bean.productCode);
        }

        if (!TextUtils.isEmpty(bean.outCount)) {
            viewBinding.textNumber.setText(bean.outCount);
        }

        if (!TextUtils.isEmpty(bean.outCountProportion)) {
            viewBinding.textNumberProportion.setText(bean.outCountProportion);
        }

        if (!TextUtils.isEmpty(bean.outSum)) {
            viewBinding.textAmount.setText(bean.outSum);
        }
        if (!TextUtils.isEmpty(bean.outSumProportion)) {
            viewBinding.textAmountProportion.setText(bean.outSumProportion);
        }

        if (type == 2) {
            viewBinding.textProfit.setVisibility(View.VISIBLE);
            viewBinding.tvProfit.setVisibility(View.VISIBLE);
            viewBinding.textProfitProportion.setVisibility(View.VISIBLE);
            viewBinding.tvProfitProportion.setVisibility(View.VISIBLE);

            if (!TextUtils.isEmpty(bean.outProfit)) {
                viewBinding.textProfit.setText(bean.outProfit);
            }
            if (!TextUtils.isEmpty(bean.outProfitProportion)) {
                viewBinding.textProfitProportion.setText(bean.outProfitProportion);
            }
        } else {
            viewBinding.textProfit.setVisibility(View.GONE);
            viewBinding.tvProfit.setVisibility(View.GONE);
            viewBinding.textProfitProportion.setVisibility(View.GONE);
            viewBinding.tvProfitProportion.setVisibility(View.GONE);
        }

        if (!TextUtils.isEmpty(bean.specification)) {
            viewBinding.textProductSpecification.setText(bean.specification);
        }
        if (!TextUtils.isEmpty(bean.cartonSize)) {
            viewBinding.textBoxingSpecification.setText(bean.cartonSize);
        }
        if (!TextUtils.isEmpty(bean.productCategory)) {
            viewBinding.textProductSort.setText(bean.productCategory);
        }
        if (!TextUtils.isEmpty(bean.price)) {
            viewBinding.textPrice.setText(bean.price);
        }
    }

    @Override
    protected void initData() throws IllegalAccessException {

    }
}